var UserImport = {
	importForm		: null,		//录入表单
	importWindow	: null,		//录入对话框
	fieldAnchor		: Common.config.fieldAnchor,
	getImportForm	: function () {
		if (this.importForm != null) {
			return this.importForm;
		}
		this.importForm = new Ext.FormPanel({
	        fileUpload: true,
            border: false,
	        frame: true,
	        labelWidth: 58,
	        bodyStyle: 'padding:5px; overflow-x:visible;overflow-y:scroll',
	        labelAlign: 'right',
	        layout: 'form',
	        items: [{
		    	xtype: 'fileuploadfield', allowBlank: false, id: 'upload',
		    	name: 'upload', fieldLabel: '导入文件',
		    	emptyText: '请选择需上传的文件', blankText: '文件不能为空', anchor: '92%',
		    	buttonCfg: {
		    		text: '',
					iconCls: 'icon_file_add'
		    	}
	    	}]
	    	
	    });
		return this.importForm;
	},
	showImportWindow : function (title) {
		if (this.importWindow == null) {
			var importForm = User.getImportForm();
			this.importWindow = new Ext.Window({ //定义对话框
				title: '用户信息录入',
				closeAction : 'hide',
				modal : true,
				shadow : true,
				closable : true,
				layout : 'fit',
				width : 420,
				height : 180,
				items:[importForm],
				buttons : [{
					text :'提交',
					iconCls: 'icon_sure',
					scope: this,
					handler: this.onSubmitImport
				},{
					text :'关闭',
					iconCls: 'icon_close',
					scope: this,
					handler: function(){ this.importWindow.hide();}
				}]
			});
			/**
            Role.roleStore.addListener("load", function (thisStore, records, options) {
		   		Role.initUserRole();
			});
            Role.loadRoleStore();	//初始化角色信息
            */
		}
		this.importWindow.show();
		this.importWindow.setTitle(title || "用户信息批量导入");
	},
	onSubmitImport : function () {
		var thisForm = UserImport.getImportForm().getForm();
		if (!thisForm.isValid()) {
			return;
		}
		Common.showProcessMsgBox("文件上传中，请稍后...");
		thisForm.submit({
			url		: FileManage.uploadConifg.uploadUrl,
            success	: function (form, action) {
            	Common.hideProcessMsgBox();
		    	FileManage.uploadWindow.hide();
		    	Ext.topShow.msg("成功提示", '用户信息导入成功.');
            },
            failure : function (form, action) {
            	Common.hideProcessMsgBox();
				Ext.Msg.show({
	                title : '失败提示',
	                minWidth: 180,
	                msg : "用户信息导入失败！",
	                buttons : Ext.Msg.OK,
	                icon: Ext.MessageBox.ERROR
	            });
            }
        });
	},
	onResetImportForm : function () {
		UserImport.importForm.remove('upload', true);
		UserImport.importForm.add({
	    	xtype: 'fileuploadfield', allowBlank: false, id: 'upload',
	    	name: 'upload', fieldLabel: '导入文件',
	    	emptyText: '请选择需上传的文件', blankText: '文件不能为空', anchor: '92%',
	    	buttonCfg: {
	    		text: '',
				iconCls: 'icon_file_add'
	    	}
    	});
		UserImport.importForm.doLayout();
	},
	onImportUser : function () {
		UserImport.showImportWindow();
		UserImport.onResetImportForm();
	}
}